//
//  OMTViewController.m
//  OMTImagePicker
//
//  Created by yizhaorong on 11/15/2017.
//  Copyright (c) 2017 yizhaorong. All rights reserved.
//

#import "OMTViewController.h"
#import "OMTAlbumManager.h"
#import "UIImageView+OMTAsset.h"
#import "OMTImagePickerController.h"
#import <YYAnimatedImageView.h>

#import "NSString+OMTImagePicker.h"

@interface OMTViewController () <OMTImagePickerControllerDelegate,UINavigationControllerDelegate>

@property (weak, nonatomic) IBOutlet YYAnimatedImageView *imageView;

@property (strong, nonatomic) OMTAlbum *album;

@end

@implementation OMTViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    
   NSString *string = [@"第${1}张" picker_replacePatternBy:[NSString stringWithFormat:@"%ld",10], nil];
    NSLog(@"====%@",string);
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    OMTImagePickerController *pickerView = [[OMTImagePickerController alloc] initWithBuilder:^(OMTImagePickerBuilder *builder) {
        builder.showVedio = YES;
        builder.shouldRecordVideo = YES;
        UIImage *(^defaultImageBlock)(NSString *imageNamed) = [builder.imageWithNamed copy];
        builder.imageWithNamed = ^UIImage *(NSString *imageNamed) {
            UIImage *image = nil;
            if ([imageNamed isEqualToString:@"omt_nav_bg"]) {
                
            } else {
                image = defaultImageBlock(imageNamed);
            }
            return image;
        };
        builder.maxSelectCount = 4;
    }];
    
//    pickerView.didFinishPickingPhotosHandle = ^(OMTImagePickerController *picker, NSArray<UIImage *> *photos, NSArray<NSData *> *imageDatas) {
//        NSLog(@"imageCount:%ld", photos.count);
//        [picker dismissViewControllerAnimated:YES completion:nil];
//    };
    [self presentViewController:pickerView animated:YES completion:nil];
}

@end
